package com.example.learnspringboot06datajdbc.mapper;

import com.example.learnspringboot06datajdbc.bean.Department;
import org.apache.ibatis.annotations.*;

//指定这是一个操作数据库的mapper  查看 MybatisAutoConfiguration 源码
//@Mapper // 这里注释掉 ，在 LearnSpringBoot06DataJdbcApplication 使用 @MapperScan 进行批量扫描
public interface DepartmentMapper {
    @Select("select * from department where id = #{id}")
    public Department getDepartById(Integer id);

    @Delete("delete from department where id=#{id}")
    public int deleteDeptById(Integer id);

    @Options(useGeneratedKeys = true,keyProperty = "id")//使用自动生成的id
    @Insert("insert into department(departmentName) values(#{departmentName})")
//    @Insert("insert into department(department_name) values(#{departmentName})")// todo 在 MybatisConfig 配置了驼峰转换
    public int insertDept(Department department);

    @Update("update department set departmentName=#{departmentName} where id=#{id}")
//    @Update("update department set department_name=#{departmentName} where id=#{id}")
    public int updateDept(Department department);
}
